<?

$username= isset($_POST['username']) ? $_POST['username'] : "";
$Email= isset($_POST['Email']) ? $_POST['Email'] : "";
$Question= isset($_POST['Question']) ? $_POST['Question'] : "";
$chatid =isset($_POST['chatid']) ? intval($_POST['chatid']) : 0;
if($chatid==0)
{
	$chatid=$GLOBALS['supportid'];
}

if(!empty($username) && !empty($Email) && !empty($Question))
{
	$Question=str_replace("\n","<br>",$Question);
	$Question=str_replace("\r","",$Question);
	$ssid=md5(rand(4,4)._TIME.$username);
	if($username==$name)$username.="2";
	
	$timeout=_TIME+_TIMEOUT_;
	$Question=$username."++".$Question."$$";
	
	$sql_insert="insert ".$GLOBALS['first_table']."tblchat(cRoomName,cEmail,cText,iTimeOut,iStatus,iUserId,cSId) 
				values('$username','$Email','$Question','".$timeout."',1,'$chatid','$ssid')";
	$dbsql->query($sql_insert);
	
	set_Cookie(_NAMECOOKIELOGINGUEST,$ssid);
	set_Cookie(_NAMESITESUPPORT,$name);
	
	$_SESSION['name']=$name;
	header("location: guest.php?name=$name");
	exit();
	
}

?>